package com.ss.android.wenda.c;

import android.view.View;

import com.bytedance.common.utility.view.DrawableCenterTextView;
import com.ss.android.action.ActionAnimView;
import com.ss.android.article.browser.R;
import com.ss.android.common.lib.MobClickCombiner;
import com.ss.android.k.c.a;
import com.ss.android.wenda.model.Answer;
import org.json.JSONException;
import org.json.JSONObject;

public final class g extends a {
    private int c;
    private String d;

    public g(int arg1, String arg2) {

        this.c = arg1;
        this.d = arg2;
    }

    static int a(g arg1) {
        return arg1.c;
    }

    public final void a(View arg5, Object arg6) {
        if((arg6 instanceof Answer)) {
            JSONObject v0 = new JSONObject();
            try {
                v0.put("is_digged", ((Answer)arg6).mSync.isDigg);
            }
            catch(JSONException v0_1) {
                v0_1.printStackTrace();
            }

            if(((Answer)arg6).isDigg()) {
                android.support.design.a.showImageToast(this.d(), R.string.dj, 0);
                return;
            }

            if(((Answer)arg6).isBury()) {
                android.support.design.a.showImageToast(this.d(), R.string.di, 0);
                return;
            }

            ((ActionAnimView)this.b().c.b(com.ss.android.article.browser.R.id.digg_anim).a).a();
            this.c().a(true);
            ((Answer)arg6).diggAnswer();
            this.b(arg6);
            switch(this.c) {
                case 1: {
                    MobClickCombiner.onEvent(arg5.getContext(), "question", "digg");
                    break;
                }
                case 2: {
                    MobClickCombiner.onEvent(arg5.getContext(), "question", "fold_digg");
                    break;
                }
            }

            android.support.design.a.a(((Answer)arg6).mAnsId, "question", this.d, new h(this, ((Answer)arg6)));
        }
    }

    public final void b(Object arg5) {
        this.c().a(((Answer)arg5).isDigg());
        if(((Answer)arg5).getDiggCount() > 0) {
            this.c().a(String.valueOf(((Answer)arg5).getDiggCount()));
        }
        else {
            this.c().c(com.ss.android.article.browser.R.string.digg);
        }

        if(((Answer)arg5).isBury()) {
            ((DrawableCenterTextView)this.c().a).setTextColor(this.c().a().getResources().getColor(com.ss.android.article.browser.R.color.ssxinzi3));
            ((DrawableCenterTextView)this.c().a).setCompoundDrawablesWithIntrinsicBounds(com.ss.android.article.browser.R.drawable.digup_video_normal, 0, 0, 0);
        }
        else if(((Answer)arg5).isDigg()) {
            ((DrawableCenterTextView)this.c().a).setTextColor(this.c().a().getResources().getColor(com.ss.android.article.browser.R.color.ssxinzi4));
            ((DrawableCenterTextView)this.c().a).setCompoundDrawablesWithIntrinsicBounds(com.ss.android.article.browser.R.drawable.digup_video_pressed, 0, 0, 0);
        }
        else {
            ((DrawableCenterTextView)this.c().a).setTextColor(this.c().a().getResources().getColor(com.ss.android.article.browser.R.color.digg_count_text));
            ((DrawableCenterTextView)this.c().a).setCompoundDrawablesWithIntrinsicBounds(com.ss.android.article.browser.R.drawable.digup_video, 0, 0, 0);
        }
    }
}

